import Mock from 'mockjs'
import { CONSTANT_OBJ } from '@/utils/constant'
let baseURL
let locationHref = `http://${window.location.hostname}`
if (CONSTANT_OBJ.ENV !== 'prodMaster') {
  baseURL = CONSTANT_OBJ.URL + CONSTANT_OBJ.PREFIX + '/case'
  // baseURL = URL
} else {
  baseURL = locationHref + CONSTANT_OBJ.PREFIX + '/case'
}
// 分页查询
Mock.mock(`${baseURL}/v1/api/case/case/basic/queryByCondition`, function () {
  return {
    ...CONSTANT_OBJ.MOCK_RESPONSE,
    data: {
      total: 2,
      list: [
        {
          caseId: '1', applyNo: '202206140707546', customerName: '小王王', caseStatus: '1', idNbr: '445111********2341', customerPhone: '185****1723', productType: '1', acceptorName: 'wew', acceptorOrgName: 'ewewe', createTime: '2022-05-22 10:10:10', statusUpdateTime: '2022-08-19 15:40:10'
        },
        {
          caseId: '2', applyNo: '202206140707547', customerName: '小王二', caseStatus: '2', idNbr: '445111********2341', customerPhone: '185****1723', productType: '1', acceptorName: 'wew', acceptorOrgName: 'ewewe', createTime: '2022-05-22 10:10:10', statusUpdateTime: '2022-08-22 11:10:10'
        }
      ]
    }
  }
})

// 通过ID查询申请件基本信息
Mock.mock(`${baseURL}/v1/api/case/case/basic/queryById/1`, function () {
  return {
    ...CONSTANT_OBJ.MOCK_RESPONSE,
    data: {
      caseId: '1',
      applyNo: '202206140707546',
      customerName: '小王王',
      acceptorNo: '23243232321',
      idNbr: '445111********2341',
      customerPhone: '185****1723',
      caseStatus: '主任审批',
      productType: '1',
      acceptorName: 'wew',
      acceptorOrgName: 'ewewe'

    }
  }
})

// 通过caseId查询申请件预批结果
Mock.mock(`${baseURL}/v1/api/case/case/basic/queryByCaseId/1`, function () {
  return {
    ...CONSTANT_OBJ.MOCK_RESPONSE,
    data: {
      suggestRate: '8.0%',
      approveAmountVos: [{ suggestAmount: 5000, preApproveLevel: '无房无学' }, { suggestAmount: 8000, preApproveLevel: '有房无学' }, { suggestAmount: 10000, preApproveLevel: '无房有学' }]

    }
  }
})

// 通过caseId查询申请件流转记录
Mock.mock(`${baseURL}/v1/api/case/case/flow/queryByCaseId/1`, function () {
  return {
    ...CONSTANT_OBJ.MOCK_RESPONSE,
    data: [
      { createTime: '2022-06-16 15:46:05', flowStep: '提交申请' },
      { createTime: '2022-06-16 15:46:05', flowStep: '受理分派' },
      { createTime: '2022-06-16 15:46:05', flowStep: '申请确认' },
      { createTime: '2022-06-16 15:46:05', flowStep: '预审批' },
      { createTime: '2022-06-16 15:46:05', flowStep: '主任审批' },
      { createTime: '', flowStep: '贷前调查' }
    ]
  }
})

// 通过caseId查询申请件跟进记录
Mock.mock(`${baseURL}/v1/api/case/case/follow/queryByCaseId/1`, function () {
  return {
    ...CONSTANT_OBJ.MOCK_RESPONSE,
    data: [
      { createTime: '2022-06-16 15:46:05', label: '提交申请' },
      { createTime: '2022-06-16 15:46:05', label: '受理分派' },
      { createTime: '2022-06-16 15:46:05', label: '申请确认' },
      { createTime: '2022-06-16 15:46:05', label: '预审批' },
      { createTime: '2022-06-16 15:46:05', label: '主任审批' },
      { createTime: '', label: '贷前调查' }
    ]
  }
})

// 通过caseId查询申请件客户信息
Mock.mock(`${baseURL}/v1/api/case/case/customer/queryByCaseId/1`, function () {
  return {
    ...CONSTANT_OBJ.MOCK_RESPONSE,
    data: {
      customerName: '王*喵',
      idNbr: '232343434',
      idAddress: '广州市天河区****',
      idEndDate: '2025-12-12',
      customerPhone: '135864233',
      homeAddress: { addressType: 'H', province: '广东省', city: '广州市', town: '天河区', street: '家庭地址' },
      maritalStatus: '已婚',
      houseStatus: '有房',
      education: '大学本科'
    }
  }
})

// 通过caseId查询申请件职业信息
Mock.mock(`${baseURL}/v1/api/case/case/career/queryByCaseId/1`, function () {
  return {
    ...CONSTANT_OBJ.MOCK_RESPONSE,
    data: {
      organName: '广东****有限公司',
      organAddress: { addressType: 'C', province: '广东省', city: '广州市', town: '越秀区', street: '单位地址' },
      organPhone: '020-*****',
      customerType: 'A类',
      departmentName: '某部门',
      positionName: '部门负责人',
      workTime: '2年及以上',
      salaryBeforeTax: '12000'
    }
  }
})

// 通过caseId查询申请件联系人信息
Mock.mock(`${baseURL}/v1/api/case/case/contact/queryByCaseId/1`, function () {
  return {
    ...CONSTANT_OBJ.MOCK_RESPONSE,
    data: [
      { contactName: '张*', contactPhone: '1356644', contactRelation: '母亲', isKnow: '是', priority: 1 },
      { contactName: '张*', contactPhone: '1356644', contactRelation: '朋友', isKnow: '否', priority: 2 }
    ]
  }
})

// 通过caseId查询申请件跟进记录
Mock.mock(`${baseURL}/v1/api/case/case/follow/queryByCaseId/1`, function () {
  return {
    ...CONSTANT_OBJ.MOCK_RESPONSE,
    data: [
      { followPerson: '跟进人1', label: '标签1', remark: 'SSDHSKDSADSA', createTime: '2022-08-24' },
      { followPerson: '跟进人2', label: '标签2', remark: 'SSDHSKDSADSA', createTime: '2022-08-24' }
    ]
  }
})

// 通过caseId查询申请件审批记录
Mock.mock(`${baseURL}/v1/api/case/case/audit/queryByCaseId/1`, function () {
  return {
    ...CONSTANT_OBJ.MOCK_RESPONSE,
    data: [
      { auditResult: '通过', auditStaff: '主任审批', auditAdvice: '备注内容备注内容备注内容', createTime: '2022-08-24' },
      { auditResult: '通过', auditStaff: '风险审批', auditAdvice: '备注内容备注内容备注内容', createTime: '2022-08-24' },
      { auditResult: '通过', auditStaff: '主任审批', auditAdvice: '需补充：公积金证明、个税证明、产权证明', createTime: '2022-08-24' }
    ]
  }
})

// 审批保存
Mock.mock(`${baseURL}/v1/api/case/case/audit/save`, function () {
  return {
    ...CONSTANT_OBJ.MOCK_RESPONSE
  }
})

// 审批提交
Mock.mock(`${baseURL}/v1/api/case/case/audit/submit`, function () {
  return {
    ...CONSTANT_OBJ.MOCK_RESPONSE
  }
})

// 分派
Mock.mock(`${baseURL}/v1/api/case/case/assign/acceptor`, function () {
  return {
    ...CONSTANT_OBJ.MOCK_RESPONSE
  }
})

// 撤回
Mock.mock(`${baseURL}/v1/api/case/case/basic/cancel`, function () {
  return {
    ...CONSTANT_OBJ.MOCK_RESPONSE
  }
})
